home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SNNSV32.ZIP / SNNSv3.2 / kernel / sources / kr_mem.ph < prev    next >
Text File  |  1994-04-25  |  9KB  |  262 lines

  1. /*****************************************************************************
  2.   FILE           : kr_mem.ph
  3.   SHORTNAME      : 
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : SNNS-Kernel Memory Manager Function Prototypes
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Niels Mache
  10.   DATE           : 21.2.90
  11.  
  12.   CHANGED BY     : Sven Doering
  13.   IDENTIFICATION : @(#)kr_mem.ph    1.12 4/7/94
  14.   SCCS VERSION   : 1.12
  15.   LAST CHANGE    : 4/7/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.  
  19. ******************************************************************************/
  20. #ifndef  _KR_MEM_DEFINED_
  21. #define _KR_MEM_DEFINED_
  22.  
  23. /* begin global definition section */
  24.  
  25.  
  26. /*  get one link structure */
  27. struct Link *krm_getLink( void );
  28.  
  29. /*  release one link structure */
  30. void krm_releaseLink( struct Link * link_ptr);
  31.  
  32. /*  release the link and all following links */
  33. void krm_releaseAllLinks( struct Link *first_link_ptr );
  34.  
  35. /*  get one unit-site structure */
  36. struct Site *krm_getSite( void );
  37.  
  38. /*  release one unit-site structure */
  39. void krm_releaseSite( struct Site *site_ptr );
  40.  
  41. /*  release the unit-site and all following sites (at this unit) */
  42. void krm_releaseAllSites( struct Site *first_site_ptr );
  43.  
  44. /*  garbage collection of unit array */
  45. void  krm_unitArrayGC( void );
  46.  
  47. /*  allocate the unit array */
  48. krui_err krm_allocUnits( int  N );
  49.  
  50. /*  get one unit structure */
  51. int krm_getUnit( void );
  52.  
  53. /*  release unit */
  54. void krm_releaseUnit( int  UnitNo );
  55.  
  56. /*  get information about memory usage */
  57. void krm_getMemoryManagerInfo( int  *array_size, int info_array[] );
  58.  
  59. /*  allocate the array for topological sorting of the units in the network */
  60. krui_err  krm_allocUnitTopoArray( int  N );
  61.  
  62. /*  release the topolocic array */
  63. void  krm_releaseUnitTopoArray( void );
  64.  
  65. /*  release one name-table entry */
  66. void krm_NTableReleaseEntry( struct NameTable  *NTable_ptr );
  67.  
  68. /*  Searches for a given symbol and symbol-type in the name table.
  69.     Returns symbol ptr if symbol was found, NULL otherwise. */
  70. struct NameTable *krm_NTableSymbolSearch( char  *symbol, int  sym_type );
  71.  
  72. /*  Creates a new symbol in the name-table.   Returns name-table ptr or NULL if
  73.     memory alloc has failed. */
  74. struct NameTable *krm_NTableCreateEntry( char  *symbol_name, int  symbol_type );
  75.  
  76. /*  Inserts a symbol in the name-table. This function duplicates symbol ptrs
  77.     if the symbol was found in the name-table.  Returns symbol ptr or NULL if
  78.     memory alloc has failed. */
  79. char *krm_NTableInsertSymbol( char  *symbol_name, int  symbol_type );
  80.  
  81. /*  release name-table entry if there is no other reference to this symbol */
  82. void krm_NTableReleaseSymbol( char  *symbol_name, int  symbol_type );
  83.  
  84. /*  get the first name-table entry */
  85. struct NameTable *krm_getNTableFirstEntry( void );
  86.  
  87. /*  get the next name-table entry */
  88. struct NameTable *krm_getNTableNextEntry( void );
  89.  
  90. /*  create new site-table entry */
  91. struct SiteTable *krm_STableCreateEntry( char  *site_symbol, SiteFuncPtr  site_func );
  92.  
  93. /*  change the properties of the given site-table entry */
  94. struct SiteTable *krm_STableChangeEntry(struct  SiteTable  *stbl_ptr, 
  95.                     char  *new_site_name,
  96.                     SiteFuncPtr  new_site_func );
  97.  
  98. /*  release a previosly defined site-table entry */
  99. void krm_STableRemoveEntry( struct SiteTable  *STable_ptr );
  100.  
  101. /*  searches for a symbol in the site-table */
  102. struct SiteTable *krm_STableSymbolSearch( char  *site_symbol );
  103.  
  104. /*  returns a pointer to the first used site-table entry */
  105. struct SiteTable *krm_getSTableFirstEntry( void );
  106.  
  107. /*  returns a pointer to the next used site-table entry */
  108. struct SiteTable *krm_getSTableNextEntry( void );
  109.  
  110. /*  allocate a new Ftype entry */
  111. struct FtypeUnitStruct *krm_getFtypeEntry( void );
  112.  
  113. /*  free a previosly defined Ftype entry */
  114. void krm_releaseFtypeEntry( struct FtypeUnitStruct  *Ftype_entry );
  115.  
  116. /*  create and define a Ftype entry */
  117. struct FtypeUnitStruct *krm_FtypeCreateEntry(char *Ftype_symbol, 
  118.                          OutFuncPtr out_func, 
  119.                          ActFuncPtr act_func, 
  120.                          ActDerivFuncPtr act_deriv_func );
  121.  
  122. /*  add a site to a previosly defined Ftype entry */
  123. struct Site *krm_FtypeAddSite(struct FtypeUnitStruct  *Ftype_entry, 
  124.                   struct SiteTable  *STable_entry );
  125.  
  126. /*  returns a pointer to first Ftype entry */
  127. struct FtypeUnitStruct *krm_getFtypeFirstEntry( void );
  128.  
  129. /*  returns a pointer to next Ftype entry */
  130. struct FtypeUnitStruct *krm_getFtypeNextEntry( void );
  131.  
  132. /*  searches for a Ftype entry with the given name */
  133. struct FtypeUnitStruct *krm_FtypeSymbolSearch( char  *Ftype_symbol );
  134.  
  135. /*  releases all Ftype entries */
  136. void krm_releaseFtypeList( void );
  137.  
  138. /*  free all link arrays */
  139. void  krm_releaseLinkArrays( void );
  140.  
  141.  
  142. /*  Functions for the MasPar kernel  */
  143. #ifdef MASPAR_KERNEL
  144. #ifdef MASPAR_KERNEL_EMULATION
  145.  
  146. /*  release weight arrays from memory */
  147. void  krm_releaseWeightArrays( void );
  148.  
  149. /*  creates arrays containing connection weights for feedforward networks */
  150. krui_err  krm_createWeightArrays( void );
  151.  
  152. #endif
  153. #endif
  154.  
  155. /*  frees all memory used for the internal representation of the network */
  156. void krm_releaseMem( void );
  157.  
  158. #ifdef KERNEL3D
  159.  
  160. extern struct TransTable  *transTable;
  161. extern int transTableSize;
  162.  
  163. #endif
  164.  
  165.  
  166. /*#################################################
  167.  
  168. GROUP: Global Var's (as declared by the Memory Manager)
  169.  
  170. #################################################*/
  171.  
  172. int  NoOfAllocPatternPairs = 0;  /*  no. of allocated pattern pairs  */
  173.  
  174.  
  175. /* end global definition section */
  176.  
  177. /* begin private definition section */
  178.  
  179.  
  180. /*#################################################
  181.  
  182. GROUP: Local Var's
  183.  
  184. #################################################*/
  185.  
  186. static int  FreeUnitIndex  = 0, /* no. of the next free unit in the unit array*/
  187.         NoOfAllocUnits = 0, /* no. of allocated units  */
  188.         NoOfSites       = 0, /* no. of used sites in the network and Ftype 
  189.                    sites (including sites for functionality 
  190.                    type use only) */
  191.         NoOfNetSites   = 0, /* no. of used sites in the network (only unit 
  192.                    sites)  */
  193.         NoOfAllocSites = 0, /* no. of allocated sites  */
  194.         NoOfLinks       = 0, /* no. of links used for the network    */
  195.         NoOfAllocLinks = 0, /* no. of allocated links  */
  196.         NoOfNTableEntries        = 0, /*no. of name table entries  */
  197.         NoOfAllocNTableEntries  = 0, /*no. of allocated name table entries*/
  198.         NoOfSTableEntries        = 0, /*no. of site table entries  */
  199.         NoOfAllocSTableEntries  = 0, /*no. of allocated site table entries*/
  200.         NoOfFTableEntries        = 0, /*no. of functionality types  */
  201.         NoOfAllocPatternNumbers = 0; /*no. of allocated array elements for
  202.                        shuffeling pattern numbers  */
  203.  
  204. static SiteArray    
  205.             site_array        = NULL,  /*  pointer to first site array  */
  206.         free_site_ptr     = NULL,  /*  pointer to first free site  */
  207.             site_block_list   = NULL;  /*  pointer to first free site block */
  208.  
  209. static LinkArray       
  210.             link_array        = NULL,  /*  pointer to first link array  */
  211.         free_link_ptr     = NULL,  /*  pointer to first free link  */
  212.         link_block_list   = NULL;  /*  pointer to first free link block */
  213.  
  214.  
  215. static NTableArray  
  216.             NTable_array      = NULL,  /* pointer to name table  */
  217.         free_NTable_entry = NULL,  /* ptr to first free name table entry  */
  218.         NTable_block_list = NULL,  /* ptr to first free name table block  */
  219.         curr_NTable_entry = NULL,  /* pointer to current name table entry */
  220.               curr_NTable_block = NULL;  /* pointer to current name table block */
  221.  
  222.  
  223. static STableArray  
  224.             STable_array      = NULL,  /* pointer to site table  */
  225.             free_STable_entry = NULL,  /* ptr to first free site table entry  */
  226.         STable_block_list = NULL,  /* ptr to first free site table block  */
  227.         curr_STable_entry = NULL,  /* pointer to current name site entry  */
  228.         curr_STable_block = NULL;  /* pointer to current name site block  */
  229.  
  230.  
  231. static struct FtypeUnitStruct  
  232.             *Ftype_list_root  = NULL,  /*  pointer to root of the Ftype list  */
  233.             *curr_Ftype_entry = NULL;  /*  pointer to current Ftype entry  */
  234.  
  235.  
  236. static  int krm_allocLinks(int N);
  237. static  int krm_allocSites(int N);
  238. static struct Site  *krm_getFtypeSite(void);
  239.  
  240. /* Future Use: release one Ftype-site structure */
  241. /*static void    krm_releaseFtypeSite(struct Site *site_ptr ); */
  242.  
  243. static void krm_releaseAllFtypeSites(struct Site *first_site_ptr);
  244. static void krm_releaseSiteArrays(void);
  245. static void krm_relocateLinkPtrs(int offset);
  246. static void krm_releaseUnitArrays(void);
  247. static int  krm_allocNTableArray(void);
  248. static struct NameTable  *krm_getNTableEntry(void);
  249. static void krm_releaseNTableArrays(void);
  250. static int  krm_allocSTableArray(void);
  251. static int  krm_allocSTableArray(void);
  252. static struct SiteTable    *krm_getSTableEntry(void);
  253. static void krm_releaseSTableEntry(struct SiteTable *STable_ptr);
  254. static void krm_releaseSTableArrays(void);
  255. static struct SiteTable       *krm_getSTableNextRawEntry(void);
  256.  
  257.  
  258. /* end private definition section */
  259.  
  260. #endif 
  261.  
  262.